<template>
	<view class="box">
		<view class="head">
			<image class="img" :src="info.image"></image>
			<view class="content_box">
				<view class="name">{{info.name}}</view>

				<view class="ibox">
					<view class="left">
						<u-icon name="clock" color="#92948B"></u-icon>
						<text class="right">活动时间:</text>
					</view>
					
					<view class="time">{{info.timeText}}</view>
				</view>
				<view class="ibox">
					<view class="left">
						<u-icon name="clock" color="#92948B"></u-icon>
						<text class="right">报名时间:</text>
					</view>
					
					<view class="time">{{info.timeTexts}}</view>
				</view>
				<view class="ibox">
					<view class="left">
						<u-icon name="map" color="#92948B"></u-icon>
						<text class="right">活动地点:</text>
					</view>
					
					<view class="time">{{info.site}}</view>
				</view>
				<view class="ibox">
					<view class="left">
						<u-icon name="man-add" color="#92948B"></u-icon>
						<text class="right">活动名额:</text>
					</view>
					
					<view class="time">{{info.buyNum}}/{{info.num}}</view>
				</view>
				<view class="ibox">
					<view class="left">
						<u-icon name="account" color="#92948B"></u-icon>
						<text class="right">联系人:</text>
					</view>
					
					<view class="time">{{info.lxr}}</view>
				</view>
				<view class="ibox">
					<view class="left">
						<u-icon name="phone" color="#92948B"></u-icon>
						<text class="right">咨询热线:</text>
					</view>
					
					<view class="time">{{info.mobile}}</view>
				</view>
			</view>
		</view>

        <view class="c_box">
			<view class="c_title">活动说明</view>
			<view class="t_box">
				<rich-text :nodes="info.content" v-if="info.content"></rich-text>
			</view>
		</view>
		
		<view class="submit blue" v-if="info.is" @click="show=true">
			{{info.isMsg}}
		</view>
		<view class="submit no" v-else>
			{{info.isMsg}}
		</view>
		
		
		          <u-popup v-model="show" mode="center">
					<view class="p_head blue">请认真填写信息</view>
					
					<view class="pi_box">
						<input class="ip" v-model="form.name" placeholder="请输入姓名" />
						<input class="ip" v-model="form.mobile" placeholder="请输入电话" />
						<input class="ip" v-model="form.num" placeholder="请输入参与人数" />
						<textarea class="ip iptext" v-model="form.remark" placeholder="请输入备注说明" />
					    <view class="p_submit blue" @click="submit">确认提交</view>
					</view>
					
					
				</u-popup>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					id:'',
				  name:'',
					  mobile:'',
					  num:1,
					  remark:''
				},
				params: {
					id: ''
				},
				info: {},
				show:false
			}
		},
		onLoad(e) {
			if (e.id) {
				this.params.id = e.id;
				this.form.id=e.id;
			}
			this.getInfo();
			this.getAddress();
		},
		methods: {
			submit(){
			    this.$post(this.$api.eventAdd,this.form,res=>{
					let data=res.data;
					if(data.code==1){
						this.show=false;
						this.$Toast(data.msg);
						this.getInfo();
						
					}else{
						this.$Toast(data.msg);
					}
				});
			},
			getAddress(){
				let params={token:uni.getStorageSync('userToken'),status:2};
				this.$get(this.$api.aduitInfo,params,res=>{
					let data=res.data;
					if(data.code==1){
						this.form.name=data.data.nickname;
						this.form.mobile=data.data.mobile;
					}
				});
			},
			getInfo() {
				this.$get(this.$api.eventInfo, this.params, res => {
					let data = res.data;
					if (data.code == 1) {
						if(data.data.content){
							data.data.content = this.$formatRichText(data.data.content).replace(/src="\//g,
								'src="' + getApp().globalData
								.imgRemote + '/');
						}
						this.info = data.data;
						
						
						
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		box-sizing: border-box;
		padding: 20rpx;
	}

	.img {
		width: 100%;
		height: 350rpx;
		border-radius: 15rpx;
	}

	.head {
		box-sizing: border-box;
		padding: 10rpx;
		border-radius: 15rpx;
		background-color: white;
	}
	.content_box{
		box-sizing: border-box;
		padding: 10rpx 0 10rpx 15rpx;
	}
	.name{
		font-weight: bold;
		margin: 5rpx 0 10rpx 0;
	}
	.ibox{
		display: flex;
		align-items: center;
		font-size: 28rpx;
		margin-top:8rpx;
	}
	.time{
		width: 75%;
	}
	.left{
		width: 25%;
	}
	.right{
		margin-left:10rpx;
	}
	.c_box{
		box-sizing: border-box;
		padding:0rpx 10rpx 20rpx 10rpx;
		border-radius: 15rpx;
		background-color: white;
	}
	.c_title{
		margin-top: 20rpx;
		box-sizing: border-box;
		padding: 20rpx 20rpx;
		border-bottom: 1rpx solid #E1E1E1;
		font-weight: bold;
	}
	.t_box{
		box-sizing: border-box;
		padding: 20rpx 0 0 0;
		font-size: 28rpx;
	}
	.submit{
		position: fixed;
		bottom: 0;
		left:0;
		width: 100%;
		box-sizing: border-box;
		padding: 35rpx 0;
		text-align: center;
		color: white;
	}
	.no{
		background-color: #B2B2B2;
	}
	.blue{
		background-color:#557EFA ;
	}
	.p_head{
		color: white;
		text-align: center;
		box-sizing: border-box;
		padding: 25rpx 0;
		width: 550rpx;
		}
		
		.pi_box{
			box-sizing: border-box;
			padding:30rpx 0;
			display: flex;
			flex-direction: column;
			align-items: center;
		}
		.ip{
			border: 1rpx solid #E3E3E3;
			width:80%;
			height: 80rpx;
			box-sizing: border-box;
			padding: 0 0 0 15rpx;
			margin-bottom:20rpx;
		}
		.iptext{
			box-sizing: border-box;
			padding: 15rpx 0 0 15rpx;
			height: 150rpx;
		}
		.p_submit{
			box-sizing: border-box;
			padding: 15rpx;
			text-align: center;
			width:80%;
			color: white;
			border-radius: 15rpx;
			margin-top: 15rpx;
		}
</style>